package com.mark.planewar.entity;

import java.awt.Graphics;
import java.awt.Image;

import com.mark.planewar.constant.Constant;
import com.mark.planewar.core.Images;
import com.mark.planewar.core.PlaneWarObject;

public class BackGround extends PlaneWarObject{
	private static Image img = Images.imgs.get("bg1");
	private int x = 0;
	private int y1 = -img.getHeight(null);
	private int y2 = 0;
	private int speed = 5;
	
	public BackGround() {
		
	}
	
	public void draw(Graphics g) {
		g.drawImage(img, x, y1, null);
		g.drawImage(img, x, y2, null);
		move();
	}
	public void move() {
		if(y2>Constant.GAME_HEIGHT) {
			y2 = y1 - img.getHeight(null);
		}
		if(y1>Constant.GAME_HEIGHT) {
			y1 = y2 - img.getHeight(null);
		}
		y1 += speed;
		y2 += speed;
	}

}
